package com.calm.editor.servlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import org.apache.catalina.websocket.StreamInbound;
import org.apache.catalina.websocket.WebSocketServlet;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
@SuppressWarnings("deprecation")
public class HelloWebSocketServlet extends WebSocketServlet {  
    private static final long serialVersionUID = 1L;  
    private ApplicationContext context;
    @Override
    public void init(ServletConfig config) throws ServletException {
    	super.init(config);
    	ServletContext servletContext = config.getServletContext();
    	context=WebApplicationContextUtils.getWebApplicationContext(servletContext);
    }
	@Override  
    protected StreamInbound createWebSocketInbound(String arg0,  
            HttpServletRequest request) {  
        return new HelloMessageInbound(context,request);
    }  
}  